package com.microservice.api.consumer.fallbackFactory;

import com.microservice.api.consumer.RemoteConsumerService;
import com.microservice.core.domain.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RemoteConsumeFallbackFactory implements FallbackFactory<RemoteConsumerService> {
    @Override
    public RemoteConsumerService create(Throwable cause) {
        return new RemoteConsumerService(){
            @Override
            public AjaxResult getConsumeMessage() {
                log.error("获取消费信息失败:{}",cause.getMessage(),cause);
                return AjaxResult.error("AjaxResult获取消费信息失败");
            }

            @Override
            public AjaxResult consumeMessagePost() {
                log.error("提交消费者信息失败:{}",cause.getMessage(),cause);
                return AjaxResult.error("AjaxResult提交消费者信息失败");
            }
        };
    }
}
